package transactions;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

import tables.Badge;
/**
 *Creation d'un badge 
 *
 */
public class CreerBadge implements transactions.Transaction_SUPER {

	private java.sql.Connection conn;
	private String etat;
	
	public CreerBadge(java.sql.Connection pConn, String pEtat){
		this.conn = pConn;
		this.etat = pEtat.toUpperCase();
	}
	
	
	public void query() throws SQLException{
		try {
			conn.setAutoCommit(false);
			conn.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
			Statement stat = conn.createStatement();
			
			//insertion d'un nouveau badge
			String cmd = new Badge(0,etat).insert();
			stat.executeQuery(cmd);
			conn.commit();
		} catch (SQLException e) {
			System.out.println("Erreur lors de l'insertion");
			conn.rollback();
			e.printStackTrace();
		}
		
	}
	
}
